#include<stdlib.h>//目前存在连在一起的问题没解决
#include<stdio.h>
typedef struct number
{
    int data;
    struct number *ptr;
}num;

num*  addnum(num *head,int adddata )
{
    num *current=head;
    num *add=(num*)malloc(sizeof(num));
    if(head==NULL)
    {
        head=add;
    }
   else
   {
        while(current->ptr!=NULL)
        {
            current=current->ptr;
        }
        current->ptr=add;
    }
    add->data=adddata;
    add->ptr=NULL;
    return head;
}

num* serchtie(num* head,int x)
{
    num *tem=head;
    while(tem!=NULL){
        if(tem->data==x)
        {
            return tem;
        }
        tem=tem->ptr;
    }
    
}

num* serchhead(num* head,int x)
{
    num* tem=head;
    if(x==tem->data)
    {
        return tem;
    }
    while(tem->ptr!=NULL)
    {
        if((tem->ptr)->data==x)
        {
            return tem;
        }
        tem=tem->ptr;
    }
}
num* swapnum(num* head,int a,int b,int c,int d)
{
    num*x=serchhead(head,a);
    num*y=serchtie(head,b);
    num*m=serchhead(head,c);
    num*n=serchtie(head,d);

    if(a==head->data)
    {
       if(y==m)
        {
            num *tem1,*tem2;
            tem1=head;
            tem2=n->ptr;
            head=m->ptr;
            n->ptr=tem1;
            y->ptr=tem2;
        }else{
                 num*tem2;
                 tem2=n->ptr;
                 head=m->ptr;
                 n->ptr=y->ptr;
                 m->ptr=x;
                 y->ptr=tem2;
        }
      

        
    }else{
        if(y==m)
        {
            num *tem1,*tem2;
            tem1=x->ptr;
            tem2=n->ptr;
            x->ptr=m->ptr;
            n->ptr=tem1;
            y->ptr=tem2;
        }
        else
        {
            num*tem1,*tem2;
            tem1=x->ptr;
            tem2=n->ptr;
            x->ptr=m->ptr;
            n->ptr=y->ptr;
            m->ptr=tem1;
            y->ptr=tem2;
        }
    }
    return head;
}

void shownum(num* head)
{
    int flag=0;
    num* current=head;
    printf("The new list is:");
    while(current->ptr!=NULL&&flag<100)
    {
        flag++;
        printf("%d ",current->data);
        current=current->ptr;
    }
    printf("%d\n",current->data);
    
    
}

void delenum(num *head)
{
    num*current=head;
    while(current->ptr!=NULL)
    {
        current=current->ptr;
        free(head);
        head=current;
    }
}












int main()
{
    int a,s1,t1,s2,t2;
    num* head=NULL;
    while(1)
    {
        scanf("%d",&a);
        if(a==-1)
        {
            break;
        }
        else{
           head=addnum(head,a);
        }
    }

    scanf("%d%d%d%d",&s1,&t1,&s2,&t2);
    head=swapnum(head,s1,t1,s2,t2);
    shownum(head);
    delenum(head);
      
   
   
    
    
    return 0;
}